export const payProviderEnum = {
    wx: {value: 1, label: "微信", icon: '/static/pay/wechat.png'},
    ali: {value: 2, label: "支付宝", icon: '/static/pay/alipay.png'},
    balance: {value: 3, label: "余额", icon: '/static/pay/balance.png'},
}

export const payTypeEnum = {
    wx_ma: {value: 1, label: "微信小程序支付", provider: payProviderEnum.wx},
    wx_app: {value: 2, label: "微信APP支付", provider: payProviderEnum.wx},
    wx_scan: {value: 3, label: "微信扫码支付", provider: payProviderEnum.wx},
    wx_h5: {value: 4, label: "微信h5支付", provider: payProviderEnum.wx},
    wx_mp: {value: 5, label: "微信公众号支付", provider: payProviderEnum.wx},
    ali: {value: 6, label: "支付宝", provider: payProviderEnum.ali},
    ali_h5: {value: 7, label: "支付宝H5支付", provider: payProviderEnum.ali},
    ali_app: {value: 8, label: "支付宝APP支付", provider: payProviderEnum.ali},
    balance: {value: 9, label: "余额支付", provider: payProviderEnum.balance},
}

export const DeviceTypeEnum = {
    h5: {
        value: "h5",
        label: "h5端",
        supportPay: [payTypeEnum.balance, payTypeEnum.ali_h5]
    },
    wx_ma: {
        value: "wxMa",
        label: "微信小程序",
        supportPay: [payTypeEnum.balance]
    },
    wx_mp: {
        value: "wxMp",
        label: "微信公众号",
        supportPay: [payTypeEnum.balance, payTypeEnum.ali_h5]
    },
    app: {
        value: "app",
        label: "app",
        supportPay: [payTypeEnum.balance, payTypeEnum.wx_app, payTypeEnum.ali_app]
    },
    ios: {
        value: "ios",
        label: "ios",
        supportPay: [payTypeEnum.balance, payTypeEnum.wx_app, payTypeEnum.ali_app]
    },
    admin: {
        value: "admin",
        label: "pc管理端",
        supportPay: []
    },
}

let current = DeviceTypeEnum.app

// #ifdef H5
current = DeviceTypeEnum.h5
if (navigator && navigator.userAgent) {
    const ua = navigator.userAgent.toLowerCase()
    if (/micromessenger/i.test(ua)) {
        current = DeviceTypeEnum.wx_mp
    }
}
// #endif

// #ifdef MP-WEIXIN
current = DeviceTypeEnum.wx_ma
// #endif

// #ifdef APP-PLUS
current = DeviceTypeEnum.app
const systemInfo = uni.getSystemInfoSync()
if (systemInfo.platform === 'ios') {
    current = DeviceTypeEnum.ios
}
if (systemInfo.platform === 'android') {
    current = DeviceTypeEnum.app
}
// #endif

Object.defineProperty(DeviceTypeEnum, 'value', {
    get() {
        return current.value
    }
})

Object.defineProperty(DeviceTypeEnum, 'label', {
    get() {
        return current.label
    }
})
Object.defineProperty(DeviceTypeEnum, 'supportPay', {
    get() {
        return current.supportPay
    }
})
